﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shsc.Net.Common.Validator.Validators;

namespace Shsc.Net.Common.Validator.Attributes
{
    /// <summary>
    /// 日期验证
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class DateCheckAttribute : BaseValidationAttribute
    {
        /// <summary>
        /// 
        /// </summary>
        private const string ERROR_MESSAGE_ID = "HE_90002";

        /// <summary>
        /// 
        /// </summary>
        public string DatePattarn { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_datePattarn"></param>
        public DateCheckAttribute(string _datePattarn)
        {
            this.DatePattarn = _datePattarn;
            this.ErrorMessageId = ERROR_MESSAGE_ID;
        }

        /// <summary>
        /// 
        /// </summary>
        public DateCheckAttribute(string _datePattarn, string[] _tagerAction)
        {
            this.DatePattarn = _datePattarn;
            this.ErrorMessageId = ERROR_MESSAGE_ID;
            this.TagerAction = _tagerAction;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_datePattarn"></param>
        /// <param name="_tagerAction"></param>
        /// <param name="_errorMessageId"></param>
        /// <param name="_errorMessageResourceName"></param>
        public DateCheckAttribute(string _datePattarn,
            string[] _tagerAction,
            string _errorMessageId,
            string _errorMessageResourceName)
        {
            this.DatePattarn = _datePattarn;
            this.ErrorMessageId = _errorMessageId;
            this.ErrorMessageResourceName = _errorMessageResourceName;
            this.TagerAction = _tagerAction;
        }

        /// <summary>
        /// 创建验证器
        /// </summary>
        /// <returns></returns>
        protected override BaseValidator CreateValidator()
        {
            return new DateValidator();
        }
    }
}
